<%@page import="ext.tianma.part.report.searchAPL.service.APLService"%>
<%@page import="org.json.JSONArray"%>
<%@page import="ext.tianma.bom.util.EnumerationUtil"%>
<%@page import="java.util.Map"%>
<%@page import="ext.tianma.part.AVLMaterial.AVLUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="jca" uri="http://www.ptc.com/windchill/taglib/components"%>
<%@ taglib prefix="w" uri="http://www.ptc.com/windchill/taglib/wrappers"%>
<%@ taglib uri="http://www.ptc.com/windchill/taglib/mvc" prefix="mvc"%>
<%@ taglib uri="http://www.ptc.com/windchill/taglib/fmt" prefix="fmt"%>
<%@ include file="/netmarkets/jsp/components/beginWizard.jspf" %>
<%
	/* Map<String, String> ranges = AVLUtil.getIBARangeValue(); //八大使用范围的内部名称、显示名称
	
	//APL材料进阶报告生命周期
	Map<String,String> levels = EnumerationUtil.getEnumerationValues("Level"); //等级枚举 */
	
	//查询二级物料分类
	JSONArray nodes = new JSONArray();
	APLService as = new APLService();
	as.recursionClassificationNodeById(null, "二级物料", true, nodes);
%>
<table>
	<tr>
		<%-- <td width=300>
			<label>使用范围：</label>
			<!-- <input type="text" name="usableRange" id="usableRange" style="width:200px" onkeydown="if(event.keyCode==13){search()}" maxlength="100"/> -->
			<select name="usableRange" id="usableRange" style="width:200px" onkeydown="if(event.keyCode==13){search()}" maxlength="100">
				<option value="">--请选择使用范围--</option>
				<%
					int i = 0;
					for(String range : ranges.keySet()) {
						String levelValue = ranges.get(range);
						String id = range + "_" + i;
				%>		
					<option value="<%= range%>"><%= levelValue%></option>
				<%		
						i++;
					}
				%>
			</select>
		
		</td>
		<td width=300>
			<label>材料状态：</label>
			<!-- <input type="text" name="materialState" id="materialState" style="width:200px" onkeydown="if(event.keyCode==13){search()}" maxlength="100"/> -->
			<select name="materialState" id="materialState" style="width:200px" onkeydown="if(event.keyCode==13){search()}" maxlength="100">
				<option value="">--请选择材料状态--</option>
				<%
					int j = 0;
					for(String level : levels.keySet()) {
						String levelValue = levels.get(level);
				%>		
					<option value="<%= level%>"><%= levelValue%></option>
				<%		
						j++;
					}
				%>
			</select>
		</td> --%>
		
		<td width=300>
			<label>二级物料：</label>
			<select name="classId" id="classId" style="width:200px" onkeydown="if(event.keyCode==13){search()}" maxlength="100">
				<option value="">--请选择二级物料--</option>
				<%
					for(int a = 0 ; a < nodes.length(); a++ ) {
						String key = nodes.getJSONObject(a).getString("key");
						String value = nodes.getJSONObject(a).getString("value");
				%>		
					<option value="<%= key%>"><%= value%></option>
				<%		
					}
				%>
			</select>
		</td>
		<td width=300>
			<label>材料型号：</label>
			<input name="MaterialType" id="MaterialType" style="width:200px" onkeydown="if(event.keyCode==13){search()}" maxlength="100" />
		</td>
		
		
		<td >
			<input type="button" name="searchButton" id="searchButton" value="查询"  onClick="search();"/>
		</td>
	</tr>
</table>

<script type="text/javascript">
	/* function search() {
		var usableRange = document.getElementById('usableRange').value;
		var materialState = document.getElementById('materialState').value;
		if("" == usableRange || "" == materialState) {
			alert("请同时输入使用范围和材料状态");
			//JCAAlert("com.ptc.core.agreements.agreementsResource.NOTHING_SELECTED");
			return false;
		} else {
			var params = {
				usableRange : usableRange,
				materialState:materialState
			};
			PTC.jca.table.Utils.reload('ext.tianma.part.RawMaterial.builder.SearchRawMaterialTableBuilder',params, true);
		}
	} */
	function search() {
		var classId = document.getElementById('classId').value;
		var MaterialType = document.getElementById('MaterialType').value;
		if("" == classId && "" == MaterialType) {
			alert("请至少输入一个查询条件");
			return false;
		} else {
			var params = {
				classId : classId,
				MaterialType:MaterialType
			};
			PTC.jca.table.Utils.reload('ext.tianma.part.RawMaterial.builder.SearchRawMaterialTableBuilder',params, true);
		}
	}
</script>
<br />
<jsp:include page="${mvc:getComponentURL('ext.tianma.part.RawMaterial.builder.SearchRawMaterialTableBuilder')}" flush="true"/>
<%@include file="/netmarkets/jsp/util/end.jspf"%>